RecordSet Class

A RecordSet is a group of Database records. Use the methods and properties of the RecordSet class to navigate among this set of records and edit and update individual records.

Events

None

Properties

BOF

EOF

FieldCount

RecordCount


Methods

Close

MoveFirst

DeleteRecord

MoveLast

Edit

MoveNext

Field

MovePrevious

IdxField

Update


More information available in parent classes: Object


Notes

If you are using REALbasic as a front-end in a multi-user environment, keep in mind the following. The Edit method will attempt to lock the current record to other users. If a user tries to access a locked record, the Database class Error property will return True.

The MoveNext method unlocks the current record if you previously locked it with the Edit method. It also calls the Close method of the class and the Close method of the Database class.

If you are using OpenBase as your data source and use the RecordSet class to update a record using Edit and Update you need to include the primary key column of the table. If you don't, OpenBase won't be able to find the record in order to update it.


Examples

The following example modifies a field and updates the table.

Dim db as Database
Dim rs as RecordSet
.
.
rs = db.SQLSelect("select * from employees where ID=01")
rs.Edit
rs.IdxField(2).Value ="VP"
rs.Update
db.Commit

The following method displays a RecordSet in a ListBox. It uses the Name and StringValue properties of the DatabaseField class to display the column headers and the data.

Sub DisplayRecordSet (rs as RecordSet)
  Dim i as Integer
  Dim V as String
 Listbox1.DeleteAllRows
 Listbox1.Columncount = rs.FieldCount
 Listbox1.AddRow rs.IdxField(1).Name
 Listbox1.CellBold(Listbox1.LastIndex, 0) = True
 For i = 2 to rs.FieldCount
  Listbox1.Cell(Listbox1.lastIndex, i - 1) = rs.IdxField(i).Name
  Listbox1.CellBold(Listbox1.LastIndex, i - 1) = True
 Next
 While Not rs.eof
  v = rs.IdxField(1).StringValue   //display first column
  Listbox1.AddRow v
  For i = 2 to rs.fieldcount
   Listbox1.Cell(Listbox1.lastIndex, i - 1) = rs.IdxField(i).StringValue
  next
  rs.MoveNext
 Wend

See Also

Database, Database4DServer, DatabaseField, DatabaseRecord, MySQLDatabase, ODBCDatabase, OpenBaseDatabase, OracleDatabase, PostgreSQLDatabase, REALSQLdatabase classes.